package com.ruoyi.easyfame.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.easyfame.mapper.ExpertScheduleMapper;
import com.ruoyi.easyfame.domain.ExpertSchedule;
import com.ruoyi.easyfame.service.IExpertScheduleService;

/**
 * 专家排班Service业务层处理
 * 
 * @author xhb
 * @date 2025-08-20
 */
@Service
public class ExpertScheduleServiceImpl implements IExpertScheduleService 
{
    @Autowired
    private ExpertScheduleMapper expertScheduleMapper;
    @Autowired
    private ISysUserService  sysUserService;

    /**
     * 查询专家排班
     * 
     * @param id 专家排班主键
     * @return 专家排班
     */
    @Override
    public ExpertSchedule selectExpertScheduleById(Long id)
    {
        return expertScheduleMapper.selectExpertScheduleById(id);
    }

    /**
     * 查询专家排班列表
     * 
     * @param expertSchedule 专家排班
     * @return 专家排班
     */
    @Override
    public List<ExpertSchedule> selectExpertScheduleList(ExpertSchedule expertSchedule)
    {
        List<ExpertSchedule> list =  expertScheduleMapper.selectExpertScheduleList(expertSchedule);
        for (ExpertSchedule schedule : list) {
            schedule.setExpertName(sysUserService.selectUserById(schedule.getExpertId()).getNickName());
        }
        return list;
    }

    /**
     * 新增专家排班
     * 
     * @param expertSchedule 专家排班
     * @return 结果
     */
    @Override
    public int insertExpertSchedule(ExpertSchedule expertSchedule)
    {
        expertSchedule.setCreateTime(DateUtils.getNowDate());
        return expertScheduleMapper.insertExpertSchedule(expertSchedule);
    }

    /**
     * 修改专家排班
     * 
     * @param expertSchedule 专家排班
     * @return 结果
     */
    @Override
    public int updateExpertSchedule(ExpertSchedule expertSchedule)
    {
        expertSchedule.setUpdateTime(DateUtils.getNowDate());
        return expertScheduleMapper.updateExpertSchedule(expertSchedule);
    }

    /**
     * 批量删除专家排班
     * 
     * @param ids 需要删除的专家排班主键
     * @return 结果
     */
    @Override
    public int deleteExpertScheduleByIds(Long[] ids)
    {
        return expertScheduleMapper.deleteExpertScheduleByIds(ids);
    }

    /**
     * 删除专家排班信息
     * 
     * @param id 专家排班主键
     * @return 结果
     */
    @Override
    public int deleteExpertScheduleById(Long id)
    {
        return expertScheduleMapper.deleteExpertScheduleById(id);
    }
}
